<template>
  <div v-if="route.path !== '/'" class="header-placeholder"></div>
  <header class="header" :class="{ 'home-header': route.path === '/' }">
    <div class="logo">
      <div class="logo">
        <h1 :class="{ 'text-dark': route.path !== '/' }">Support</h1>
      </div>
    </div>
    <nav class="nav-menu">
      <ul>
          <li v-for="item in topBtnArr" :key="item.id">
            <span :class="{ 'text-dark': route.path !== '/' }" @click="clickButton(item)">{{item.name}}</span>
          </li>
      </ul>
    </nav>
  </header>
</template>

<script setup>
const router = useRouter() 
const route = useRoute()
const topBtnArr = ref([
  {
    id: 0,
    name: '首页',
    link: '/'
  },
  {
    id: 1,
    name: '解决方案',
    link: '/solution'
  },
  {
    id: 2,
    name: '成功案例',
    link: '/case'
  },
  {
    id: 3,
    name: '优势',
    link: '/advantage'
  },
  {
    id: 4,
    name: '客户',
    link: '/client'
  }
])

const clickButton = (item) => {
  router.push(item.link)
}
</script>

<style scoped>
.header-placeholder {
  height: 70px;
  width: 100%;
  border-bottom: 1px solid #eee; /* 添加底部边框 */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); 
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 70px;
  background-color: #fff; /* 非首页时的背景色 */
}

/* 首页特殊样式 */
.home-header {
  background-color: transparent;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: transparent;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #fff;
}

.logo .text-dark{
  color: #333;
}

.nav-menu ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 2rem;
}

.nav-menu span {
  color: #fff;
  font-size: 1rem;
  transition: color 0.3s ease;
  cursor: pointer;
}

.nav-menu .text-dark {
  color: #333 !important;
}
.nav-menu .text-dark:hover  {
  color: skyblue !important;
}

.nav-menu span:hover {
  color: #666;
}
</style>